package com.woniuxy.main.dynamic_lzq.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.main.dynamic_lzq.pojo.Dynamic;
import com.woniuxy.main.dynamic_lzq.pojo.DynamicComment;

public interface DynamicMapper {
	
	@Insert("insert into dynamic(user_id,dynamic_detail,dynamic_createtime,img1) values(#{user_id},#{dynamic_detail},"
			+ "#{dynamic_createtime},#{img1})")
	void addDynamic(Dynamic dynamic);
	
	@Select("select * from dynamic where user_id = #{user_id}  order by dynamic_createtime desc limit 0,2")
	List<Dynamic> findDynamicByUid(int user_id);
	
	@Insert("insert into dynamic_comment(user_id,dynamic_id,comment_detail,comment_createtime) "
			+ "values(#{user_id},#{dynamic_id},#{comment_detail},#{comment_createtime})")
	void addComment(DynamicComment comment);
	
	@Select("select * from dynamic_comment where dynamic_id=#{dynamic_id}")
	List<DynamicComment> findCommentByDynamicId(int dynamic_id);
	
	@Select("select user_id from dynamic_comment where dynamic_id=#{dynamic_id}")
	List<Integer> findUidsByDynamicId(int dynamic_id);
	
	@Select("select  dynamic_detail,dynamic_praise,img1,img2 from dynamic where dynamic_id = #{dynamic_id}")
	Dynamic findDynamicByDynamicId(int dynamic_id);
	
	@Update("update dynamic set dynamic_praise=#{dynamic_praise} where dynamic_id = #{dynamic_id}")
	void updatePraise(Dynamic dynamic);

	
}
